﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Xml.Linq;
using Microsoft.SqlServer.Server;
using System.Xml;
using System.Threading;
using System.Net.Mail;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;

namespace Backuper
{
    public partial class Form1 : Form
    {
        //int[] datesToSendBackup = { 1, 8, 15, 23 };
        bool backupSent = false;
        EmailService emailService;

        public Form1()
        {
            InitializeComponent();
            emailService = new EmailService((EmailService.EmailServiceName)int.Parse(Utils.GetSetting("ServiceName")),
               Utils.GetSetting("Email"), Utils.GetSetting("Password"));
           /* if (!backupSent && datesToSendBackup.Contains(DateTime.Today.Day) || true)
            {*/
                MailMessage message;
                message = new MailMessage(new MailAddress("ami@maximedia-pr.co.il", "MaxiMedia Backup Server"), new MailAddress("ami@maximedia-pr.co.il"));
                message.IsBodyHtml = true;
                message.Subject = "גיבוי לקבצי מידע " + DateTime.Today.Date;
                message.Attachments.Add(new Attachment(Utils.GetSetting("HistoryPath")));
                message.Attachments.Add(new Attachment(Utils.GetSetting("ContactsPath")));
                backupSent = emailService.sendMessage(message);
                this.Close();
           /* }
            if (backupSent && !datesToSendBackup.Contains(DateTime.Today.Day))
                backupSent = false;
            */
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
        }
    }
}
